Interactive

This page includes our interactive widgets:

Description: A review score vs. price explorer with filters for rating and maximum price

These tools allow users to explore how price varies across neighborhoods and how it relates to guest ratings.

For a demonstration of an interactive widget, see @interact.

Code
import pandas as pd
from pathlib import Path
import plotly.io as pio
pio.renderers.default = "iframe"

data_path = Path("C:/Users/adans/OneDrive/Documents/Data Science/Project25/_Final Project - Boston Airbnb/~Final Project - Boston Airbnb/Data/LA_Airbnb_ALL.csv")

df = pd.read_csv(data_path)
# Load LA Airbnb Data
import pandas as pd
from pathlib import Path

data_path = Path("C:/Users/adans/OneDrive/Documents/Data Science/Project25/_Final Project - Boston Airbnb/~Final Project - Boston Airbnb/Data/LA_Airbnb_ALL.csv")

df = pd.read_csv(data_path)


# Missing Values
missing = df.isna().sum().sort_values(ascending=False)


# Top 3 Missing Values
top3_missing = missing.head(3)

# Clean price — robust handling
df["price_num"] = (
    df["price"]
    .astype(str)
    .str.replace(r"[\$,]", "", regex=True)
    .str.replace(",", "", regex=False)
)

df["price_num"] = pd.to_numeric(df["price_num"], errors="coerce")

# Remove missing/zero prices
df = df[df["price_num"].notna() & (df["price_num"] > 0)]
Code
### Interactive Review Score

import pandas as pd
import plotly.express as px
import ipywidgets as widgets
from ipywidgets import interact

### Interactive Review score
df_reviews = df[df['review_scores_rating'].notna()].copy()

@interact(
    min_rating=widgets.IntSlider(value=80, min=0, max=100, step=5, description='Min rating:'),
    max_price=widgets.IntSlider(value=400, min=50, max=1000, step=50, description='Max price:')
)
def review_score_widget(min_rating, max_price):
    data = df_reviews[
        (df_reviews['review_scores_rating'] >= min_rating) &
        (df_reviews['price_num'] <= max_price)
    ]
    
    title = f'Price vs Review Score (rating ≥ {min_rating}, price ≤ ${max_price})'
    
    fig = px.scatter(
        data,
        x='review_scores_rating',
        y='price_num',
        color='room_type',
        title=title,
        labels={
            'review_scores_rating': 'Review score rating',
            'price_num': 'Nightly price (USD)',
            'room_type': 'Room type'
        },
        opacity=0.6
    )
    return fig

Review Score vs. Price: This widget lets users study how nightly prices relate to review scores. Listings with higher review scores tend to have a wide range of prices, indicating that guests evaluate factors beyond price alone, such as cleanliness or amenities. Very low-rated listings are relatively rare and tend to have lower prices. Overall, the visualization suggests no strong linear relationship between price and rating.